package com.wenbing.miio.core;

import java.io.IOException;
import java.net.SocketAddress;

/**
 * 应用层的网络接口，为应用提供网络接口
 * @author wen bing
 * @projectName: miio
 * @package: com.wenbing.miio.core
 * @className: MiNerworkInterface
 * @date 2024/09/22 11:04
 **/
public class ProxyNetworkInterface implements NetworkInterface {

    /**
     * 协议栈
     */
    private NetworkInterface networkInterface;

    private SocketAddress socketAddress;

    public ProxyNetworkInterface(NetworkInterface networkInterface, SocketAddress socketAddress) {
        this.networkInterface = networkInterface;
        this.socketAddress = socketAddress;
    }

    @Override
    public void boot() {
        this.networkInterface.boot();
    }

    @Override
    public SocketAddress getAddress() {
        return this.socketAddress;
    }

    @Override
    public RowFrame receiveRowFrame() throws IOException {
        return this.networkInterface.receiveRowFrame();
    }

    @Override
    public void sendRowFrame(RowFrame frame) throws IOException {
        this.networkInterface.sendRowFrame(frame);
    }
}
